home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / boosters.arc / FSTRHEAP.ASM < prev    next >
Assembly Source File  |  1980-01-01  |  2KB  |  92 lines

  1. ;**********************************************
  2. ;
  3. ;      Procedure FStrHeap ( Page : HeapBuf;
  4. ;                              S : AnyString;
  5. ;                         var  X : ColumnType;
  6. ;                         var  Y : RowType );
  7. ;
  8. ;      Searches Page of heap for S.  If found,
  9. ;      FstrHeap sets X,Y to location of S[1].
  10. ;      If not found, sets X = 0.
  11. ;
  12. ;**********************************************
  13. FSTRHEAP proc    near
  14.     push    bp
  15.     mov    bp,sp
  16.     push    ds
  17.  
  18.     mov    bx,[bp+8]    ;  X offset
  19.     mov    [bx],0        ;  init to zero
  20. ;
  21. ;*** Determine starting address of Page
  22. ;
  23.     mov    di,[bp+268]
  24.     push    di
  25.     mov    ax,[bp+270]
  26.     mov    es,ax
  27. ;
  28. ;***  Find string S on page
  29. ;
  30.     mov    cx,4000
  31.     xor    dh,dh
  32.     xor    ah,ah
  33. ;
  34. INIT:    lea    bx,[bp+13]
  35.     mov    al,ss:[bx]    ; 1st char of S
  36.     mov    dl,[bp+12]    ; len of S
  37. COMPARE: cmp    al,es:[di]
  38.     je    match
  39.     add    di,2
  40.     sub    cx,2
  41.     jna    notfound
  42.     jmp    compare
  43. ;
  44. MATCH:  sub     dl,1
  45.     jz    found
  46. NEXT1:    add    di,2
  47.     inc    bx
  48.     mov    al,ss:[bx]
  49.     cmp    al,es:[di]
  50.     jne    Init
  51.     sub    dl,1
  52.     jz    found
  53.     sub    cx,2
  54.     jna    notfound
  55.     jmp    next1
  56. ;
  57. ;***  Set X,Y Coordinates
  58. ;
  59. FOUND:  mov     ax,di
  60.     pop    di
  61.     sub    ax,di
  62.     mov    dl,[bp+12]    ; len of S
  63.     dec    dl
  64.     shl    dl,1
  65.     sub    ax,dl        ; s[1] addr
  66.     mov    bl,160
  67.     div    bl        ; divide AH:AL by BL
  68.     shr    ah,1
  69.     inc    ah        ; X value
  70.     inc    al        ; Y value
  71.     mov    bx,[bp+10]
  72.     mov    ds,bx        ; data seg of X,Y
  73.     mov    bx,[bp+08]    ; X offset from DS
  74.     mov    [bx],ah
  75.     mov    byte ptr [bx+1],0
  76.     mov    bx,[bp+04]    ; Y offset from DS
  77.     mov    [bx],al
  78.     mov    byte ptr [bx+1],0
  79.     jmp    return
  80. ;
  81. ;***   Not Found - pop di off stack
  82. ;
  83. NotFound: pop   di
  84. ;
  85. ;***  Return
  86. ;
  87. RETURN:
  88.     pop    ds
  89.     mov    sp,bp
  90.     pop    bp
  91.     ret    268
  92. FSTRHEAP endp